package com.time.workshop.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.time.workshop.R;
import com.time.workshop.SuperActivity;
import com.time.workshop.bean.CountyList;

public class AddressAdapter extends BaseAdapter{
	private Context context;
	private List<CountyList> list;
	private LayoutInflater inflater;
	private ViewHolder holder = null;
	public SuperActivity mSuperActivity;
	
	public AddressAdapter(Context context, List<CountyList> list) {
		this.context = context;
		this.list = list;
		this.mSuperActivity = (SuperActivity) context;
		inflater = LayoutInflater.from(context);
	}
	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = inflater.inflate(R.layout.item_address_list, null);
			holder.addressTextView = (TextView) convertView.findViewById(R.id.addressTextView);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		
		holder.addressTextView.setText(list.get(position).getNAME());
		
		return convertView;
	}
	public final class ViewHolder {
		private TextView addressTextView;
	}
	@Override
	public void notifyDataSetChanged() {
		super.notifyDataSetChanged();
	}
}
